package io.dy.termination;

import io.dy.utils.ThreadUtils;

/**
 * @author : dmj
 * @date: 2024/7/4 7:11 下午
 * @description:
 */
public class TwoPhaseTerminationMain {

    public static void main(String[] args) {
        TwoPhaseAbstractTermination twoPhaseTermination = new TwoPhaseAbstractTermination(){
            @Override
            public boolean extracted() {
                synchronized (this){
                    if(this.starting){
                        return true;
                    }
                    starting = true;
                }
                return false;
            }
        };

        twoPhaseTermination.start();

        ThreadUtils.sleepSecond(2);

        twoPhaseTermination.stop();
    }
}
